package com.ylkj.patient.moduleimpl.live;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.examination.mlib.constants.ARouterConstants;
import com.examination.mlib.constants.KitArouterConstants;
import com.example.messagemodule.utils.MessageUtils;
import com.yilijk.base.network.https.HttpUtils;
import com.yilijk.base.network.https.interceptor.httplog.HttpLogInterceptor;
import com.yilijk.base.utils.DevicesUtils;
import com.yilijk.base.utils.SharedPreferencesUtils;
import com.yljk.mcbase.provider.LiveService;
import com.yljk.mcconfig.constants.MCARouter;
import com.ylkj.patient.utils.AppReactUtils;

import java.util.HashMap;

import okhttp3.Interceptor;

/**
 * Live相关服务
 * @author : cenjunlei
 * @date : 2021/8/15 3:04 下午
 */
@Route(path = MCARouter.LIVE_SERVICE)
public class LivePatientServiceImpl implements LiveService {
    private Context mContext;

    @Override
    public void init(Context context) {
        mContext = context;
    }


    @Override
    public void onCancelLogout(Activity activity) {
        boolean b = SharedPreferencesUtils.getInstance().removeAll();
        if (b) {
            MessageUtils.logoutIM();
            ARouter.getInstance().build(ARouterConstants.CenterActivity).navigation();
            activity.finish();

        }
    }

    @Override
    public String getBaseUrl() {
        return HttpUtils.getUrl();
    }

    @Override
    public void enterDoctorStudio(long doctorId) {
        Bundle bundle = new Bundle();
        bundle.putString("doctorId", doctorId + "");
        bundle.putInt("selectIndex", 1);
        AppReactUtils.INSTANCE.push(mContext, KitArouterConstants.IM_DOCTORBUNDLE, KitArouterConstants.Message.DoctorStudio, bundle);
    }

    @Override
    public void showMyCouponPage() {
        AppReactUtils.INSTANCE.push(mContext, KitArouterConstants.MY_BUNDLE, KitArouterConstants.Mine.MyCoupon);
    }

    @Override
    public Interceptor[] getInterceptors() {
        return new Interceptor[]{new HttpLogInterceptor()};
    }

    @Override
    public HashMap<String, Object> getDeviceInfoMap() {
        return DevicesUtils.addDeviceInfo(new HashMap<>());
    }


}
